package entity;
import java.io.Serializable;
import java.util.ArrayList;

import util.MoveType;

/**
 * This is the move class.
 */
public class Move implements Serializable{
	private static final long serialVersionUID = 3504951210885416221L;
	
	ArrayList<Movable> oldItems;
	ArrayList<Movable> newItems;
	
	private MoveType moveType;
	private boolean checkpoint;
	
	/**
	 * Constructor of Move without previous moves.
	 */
	public Move(MoveType mt, boolean cp){
		oldItems = new ArrayList<Movable>();
		newItems = new ArrayList<Movable>();
		moveType = mt;
		checkpoint = cp;
	}
	
	/**
	 * Constructor of Move with previous moves.
	 */
	public Move(ArrayList<Movable> oldItems, ArrayList<Movable> newItems, MoveType mt, boolean cp){
		oldItems = new ArrayList<Movable>();
		newItems = new ArrayList<Movable>();

		oldItems.addAll(oldItems);
		newItems.addAll(newItems);

		moveType = mt;
		checkpoint = cp;
	}
	
	/**
	 * Keep the record of previous moves. 
	 */
	public void addOldItem(Movable m){
		oldItems.add(m.clone());
	}
	
	/**
	 * Keep the record of new moves.
	 */
	public void addNewItem(Movable m){
		newItems.add(m.clone());
	}

	/**
	 * Get old moves.
	 */
	public ArrayList<Movable> getOldItems(){
		return oldItems;
	}
	
	/**
	 * Get new moves. 
	 */
	public ArrayList<Movable> getNewItems(){
		return newItems;
	}

	/**
	 * Get move type of a move. 
	 */
	public MoveType getMoveType() {
		return moveType;
	}

	/**
	 * Set move type for a move. 
	 */
	public void setMoveType(MoveType moveType) {
		this.moveType = moveType;
	}

	/**
	 * Get the checkpoint of a move.
	 */
	public boolean isCheckpoint() {
		return checkpoint;
	}

	/**
	 * Set a checkpoint for a move. 
	 */
	public void setCheckpoint(boolean checkpoint) {
		this.checkpoint = checkpoint;
	}
}
